﻿Imports System.Data.OleDb

Partial Class Donate
    Inherits System.Web.UI.Page

    Protected Sub rblDonations_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles rblDonations.SelectedIndexChanged
        If rblDonations.SelectedValue = "Other" Then
            txtDonationAmount.Enabled = True
        Else
            txtDonationAmount.Enabled = False
            txtDonationAmount.Text = rblDonations.SelectedValue
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim rdrSql As System.Data.DataView =
            DirectCast(AccessDataSource2.Select(DataSourceSelectArguments.Empty), System.Data.DataView)

            lblDonations.Text = FormatCurrency(0)
            If rdrSql.Table.Rows.Count > 0 Then
                lblDonations.Text = FormatCurrency(rdrSql.Table.Rows(0)(0))
            End If

        End If
    End Sub

    Protected Sub btnDonateToCart_Click(sender As Object, e As System.EventArgs) Handles btnDonateToCart.Click
        Dim prod As New Product()
        prod.ID = 16
        prod.ImagePath = "~\images\products\empty_img.png"
        prod.Name = "Donation"
        prod.Desc = "Charitable Donation"
        prod.CanPersonalize = False
        prod.Qty = 1
        If rblDonations.SelectedValue = "Other" Then
            prod.Amount = Double.Parse(txtDonationAmount.Text)
        Else
            prod.Amount = Double.Parse(rblDonations.Text)
        End If
        UserCart.AddtoCart(prod)
        Response.Redirect("ViewCart.aspx")
    End Sub

End Class
